fix: don't advance eventlog LastSeq() until the write is confirmed - #47
Open
AmirF194 wants to merge 1 commit into
Open
fix: don't advance eventlog LastSeq() until the write is confirmed#47AmirF194 wants to merge 1 commit into
AmirF194 wants to merge 1 commit into
Conversation
Log.Append incremented l.last before attempting the write, so a failed write left LastSeq() pointing past a gap that Since() answers as empty instead of unanswerable. Session.Attach trusts since<=LastSeq() as proof the log can serve a resume, so the documented snapshot fallback never fired and a reconnecting viewer was left silently stuck. Fixes tokencanopy#46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Log.Appendincrementedl.lastbefore attempting the write, so a failed write (or flush) leftLastSeq()pointing at a seq that never made it intol.entries.Session.Attachtrustssince <= LastSeq()as proof the log can answer a resume, so when the failed Append was the most recent one,Since(since)came back empty across that gap instead of erroring, and the documented snapshot fallback never ran.Moved the
l.lastassignment to right after the write and flush succeed, next to where the entry gets appended tol.entries, so the counter and the replay buffer always move together.Added
TestFailedAppendDoesNotAdvanceLastSeq: append one entry, close the underlying file to force the next write to fail, then assertLastSeq()andSince(0)still only see the one entry that actually landed. The new test fails without the change, atLastSeq() after failed Append = 2, want 1. Raninternal/eventlogandinternal/sessionwith-race, andmake verify(module-path, protocol/control guards, full suite, build, vet) clean.Fixes #46